home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-10-25 | 756 b | 29 lines | [UVtx/UVtl] |
- // This program provides a visualization of the old Towers
- // of Hanoi problem. It demonstrates recursion, and the
- // use of library files. The library functions are in a
- // file "Towers of Hanoi.lib", in the "Lib" folder.
-
- Library ":Lib:Towers of Hanoi.lib"
-
- // the main program //
- /////////////////////////////////////
-
- doPause = 0 // pause after each move, wait for CR
- speed1 = 800
- speed2 = 1600
- thePause = 0.1
- N = GetNumberOfTowers()
- SetUp()
-
- Move(N, 1, 3, 2)
-
-
- // the recursive Move //
- /////////////////////////////////////
- Function Move(n, from, to, using)
- If n = 1
- MoveOne(1,from,to)
- Else
- Move(n-1, from, using, to)
- MoveOne(n,from, to)
- Move(n-1, using, to, from)